﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            ht.Add("香蕉","4.5元/公斤");
            ht.Add("橙子", "6元/公斤");
            ht.Add("苹果", "7元/公斤");
            ht.Add("西瓜", "2元/公斤");
            Console.WriteLine("请输入水果名称");
            string name = Console.ReadLine();
            bool flag = ht.ContainsKey(name);
            if (flag)
            {
                Console.WriteLine("您查找的水果价格为：{0}", ht[name].ToString());
            }
            else
            {
                Console.WriteLine("您查找的水果不存在！");
            }
            Console.WriteLine("所有的水果价格如下：");

            foreach (DictionaryEntry d in ht)
            {
                string key = (string)d.Key;
                string value = d.Value.ToString();
                Console.WriteLine("水果名称：{0}，水果价格：{1}", key, value);
            }
        }
    }
}
